package com.xinglai.yun.wxapi;


import android.content.Intent;
import android.os.Bundle;

import com.action.childbase.ChildBaseActivity;
import com.action.entity.event.PayResultBackEven;
import com.base.app_core.App;
import com.base.app_core.service.pressenter.NullPressenter;
import com.base.app_core.util.log.F;
import com.hwangjr.rxbus.RxBus;
import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;

public class WXPayEntryActivity extends ChildBaseActivity<NullPressenter> implements IWXAPIEventHandler {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        App.getApp().iwxapi.handleIntent(getIntent(), this);
    }

    @Override
    protected int getLayoutId() {
        return 0;
    }

    @Override
    protected void initData() {
        super.initData();
    }

    @Override
    protected void setupComponent() {
        super.setupComponent();
        getChildViewComponent().inject(this);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
    }

    @Override
    public void onReq(BaseReq req) {
        F.j("onReq");
    }

    @Override
    public void onResp(BaseResp resp) {
        F.j("onResp"+resp.errCode);
        if (resp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
            RxBus.get().post(new PayResultBackEven(resp.errCode));
        }
        this.finish();
    }
}